import { RouteRecordRaw, createRouter, createWebHashHistory } from 'vue-router'
import routes from './routes'
import { close } from '@/utils'
import { useRouterGuard } from './guard'
const allRoutes: RouteRecordRaw[] = routes

const router = createRouter({
  routes: allRoutes,
  history: createWebHashHistory(),
  // 刷新时，滚动条位置还原
  // https://router.vuejs.org/zh/guide/advanced/scroll-behavior.html
  scrollBehavior: () => ({ left: 0, top: 0 })
})

useRouterGuard(router)

router.afterEach(() => {
  close()
})

export default router
export * from './guard'
export * from './routes'
